package testdao;

import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.orz.dao.SimpleDao;
import com.orz.entity.Usertable;
import com.orz.interfaces.SimpleDaoInterface;

/**.
 * 用于简单的测试Hibernate和Spring的整合
 * 
 * @author Administrator
 * 
 */

public class TestDataSource {
	/**.
	 * 默认构造函数
	 */
	public TestDataSource() {
	}
	
	/**.
	 * 主要的测试方法,以后要修改成Junit4.0+
	 * @param args main默认的参数
	 **/
	public static void main(final String[] args) {
		ApplicationContext act = new ClassPathXmlApplicationContext(
				"applicationContext.xml");
		SimpleDao sdo = (SimpleDao) act.getBean("baseDao");
//		Usertable us=new Usertable();
//		us.setUserdesc("军军");
//		us.setUsername("小网");
//		us.setUserpwd("8213");
//		sdo.addObject(us);
//		System.out.println("保存完成");
		Usertable u2 = new Usertable();
//		List<Object> ls = sdo.getObjects(u2);
//		System.out.println(ls.size());
//		for (Object user : ls) {
//			u2 = (Usertable) user;
//			System.out.println(u2.getUserid() + u2.getUsername());
//		}
		u2.setUsername("菠菜");
		List<Object> ls = sdo.getObjects(u2);
		u2 = (Usertable) ls.get(0);
		System.out.println(u2.getUsername());
	}
}
